﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;

namespace FetchDataCompare
{
	[Transaction(TransactionMode.Manual)]
	internal class TestCmd : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			UIDocument activeUIDocument = commandData.Application.ActiveUIDocument;
			Document document = activeUIDocument.Document;
			Selection selection = activeUIDocument.Selection;
			for (;;)
			{
				try
				{
					Reference reference = selection.PickObject((Autodesk.Revit.UI.Selection.ObjectType)1, "请选择标注对象");
					Curve curve = (document.GetElement(reference) as Dimension).Curve;
					TaskDialog.Show("标注信息", curve.GetEndPoint(0).ToString() + ";" + curve.GetEndPoint(1).ToString());
					continue;
				}
				catch (Exception)
				{
				}
				break;
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
